﻿@{
    ViewData["Title"] = "添加订单";
    Layout = "_layout";
}
@{
    var Order = ViewBag.Order as List<BuyWithoutLoseMoney.Core.Models.Order>;
    var User = ViewBag.User as List<BuyWithoutLoseMoney.Core.Models.User>;
}
@model BuyWithoutLoseMoney.Core.Models.User;
<div>
    <div class="layui-card">
        <div class="layui-card-header">添加订单</div>
        <div class="layui-card-body">
            <form class="layui-form">
                <div class="layui-form-item">
                    <label class="layui-form-label">用户名称</label>
                    <div class="layui-input-block">
                         <select name="UserId" lay-verify="required">
                            @foreach (var item in User)
                            {
                                <option value="@item.Id">@item.NickName</option>
                            }
                        </select>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">商品总价</label>
                    <div class="layui-input-block">
                            <input type="text" name="TotalMoney" required lay-verify="required" placeholder="请输入商品总价" autocomplete="off" class="layui-input">
                    </div>
                </div>
                 <div class="layui-form-item">
                    <label class="layui-form-label">状态</label>
                    <div class="layui-input-block">
                        <input type="radio" name="Status" value="1" title="未付款" checked>
                        <input type="radio" name="Status" value="2" title="已付款">
                        <input type="radio" name="Status" value="3" title="未发货">
                        <input type="radio" name="Status" value="4" title="已发货">
                    </div>
                </div>
                <div class="layui-form-item layui-form-text">
                    <label class="layui-form-label">收货方式</label>
                    <div class="layui-input-block">
                            <input type="text" name="ReceivingType" required lay-verify="required" placeholder="请输入收货方式" autocomplete="off" class="layui-input">
                    </div>
                </div> 
                <div class="layui-form-item layui-form-text">
                    <label class="layui-form-label">收货地址</label>
                    <div class="layui-input-block">
                            <input type="text" name="ReceivingAddress" required lay-verify="required" placeholder="请输入收货地址" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">创建时间</label>
                    <div class="layui-input-block">
                            <input type="text" class="layui-input" name="CreateTime" id="ID-laydate-type-datetime1" placeholder="请选择创建时间">
                    </div>
                </div>、
                <div class="layui-form-item">
                    <label class="layui-form-label">到货时间</label>
                    <div class="layui-input-block">
                            <input type="text" class="layui-input" name="ArriveTime" id="ID-laydate-type-datetime2" placeholder="请选择到货时间">
                    </div>
                </div>
               
                <div class="layui-form-item">
                    <label class="layui-form-label">支付方式</label>
                    <div class="layui-input-block">
                            <input type="text" name="Paymethod" required lay-verify="required" placeholder="请输入支付方式" autocomplete="off" class="layui-input">
                    </div>
                </div>

                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <button class="layui-btn" lay-submit lay-filter="addForm">立即提交</button>
                        <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>
   @section Scripts{
    <script>
        layui.use(["form", 'layer','laydate'], function () {
            var form = layui.form;
            var $ = layui.$;
            var layer = layui.layer;
            var laydate=layui.laydate;
            laydate.render({
                elem: '#ID-laydate-type-datetime1',
                type: 'datetime'
            });
            laydate.render({
                elem: '#ID-laydate-type-datetime2',
                type: 'datetime'
            });
            //提交
            form.on('submit(addForm)', function (data) {
                $.post("/admin/order/create", data.field, function (res) {
                    if (res.isSuccess) {
                        layer.msg(res.msg, function () {
                            parent.window.location.href = "/admin/order/index";
                        });
                    } else {
                        layer.msg(res.msg);
                    }
                });
                return false;
            });
        })
    </script>
    }